package com.huangguolin.cloud.api.Catalogue.service.impl;


import com.huangguolin.cloud.api.Catalogue.entity.ApiCatalogueSearchEntity;
import com.huangguolin.cloud.api.Catalogue.repositity.ApiCatalogueDao;
import com.huangguolin.cloud.api.Catalogue.service.ApiCatalogueService;
import com.huangguolin.cloud.mybatis.entity.PtCatalogueEntity;
import com.huangguolin.cloud.mybatis.flexigrid.PagingEntity;
import com.huangguolin.cloud.mybatis.ztree.ChildTree;
import com.huangguolin.cloud.mybatis.ztree.ZtreeEntity;
import com.huangguolin.cloud.role.service.RoleService;
import com.huangguolin.cloud.spring.util.CloudUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service

public class ApiCatalogueServiceImpl implements ApiCatalogueService {
   @Resource
    private ApiCatalogueDao apiCatalogueDao;

    @Resource
    private RoleService roleService;

    @Resource
    private ApiCatalogueService apiCatalogueService;

    @Override
    public List<PtCatalogueEntity> queryCatalogueList(ApiCatalogueSearchEntity entity) {
        return apiCatalogueDao.queryCatalogueList(entity);
    }
    @Override
    public List<ChildTree> queryMenuTree() {
        List<ZtreeEntity> list = apiCatalogueService.queryMenuZtreeAll();

        List<ChildTree> childTrees= CloudUtil.changeChildTree(list);
        return childTrees;
    }

    @Override
    public List<ZtreeEntity> queryMenuZtreeAll() {
        return apiCatalogueDao.queryMenuZtreeAll();
    }

    @Override
    public boolean insertChapter(String pid, String name, String sort) {
        return apiCatalogueDao.insertChapter(pid,name,sort);
    }

    @Override
    public boolean insert(String pid, String name, String sort) {
        return apiCatalogueDao.insert(pid,name,sort);
    }

    @Override
    public void deleteUser(String userUuids) {
        String[] userIdArray = userUuids.split(",");
        apiCatalogueDao.deleteUser(userIdArray);
    }

    @Override
    public boolean addCourse(String className, String picture, String classType, String radio, String courseIntroduction) {
        return apiCatalogueDao.addCourse(className,picture,classType,radio,courseIntroduction);
    }

    @Override
    public boolean revise(String id,String className, String picture, String classType, String radio, String courseIntroduction) {
        return apiCatalogueDao.revise(id,className,picture,classType,radio,courseIntroduction);
    }

    @Override
    public Integer queryCatalogueTotal(ApiCatalogueSearchEntity entity) {
        return apiCatalogueDao.queryCatalogueTotal(entity);
    }
}
